package com.house.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.house.common.pojo.EUDataGridResult;
import com.house.mapper.HousedesignMapper;
import com.house.pojo.Housedesign;
import com.house.pojo.HousedesignExample;

import com.house.pojo.HousedesignExample.Criteria;
import com.house.service.HousedesignService;

@Service
public class HousedesignServiceImpl implements HousedesignService {
	@Autowired
	private HousedesignMapper housedesignMapper;
	
	@Override
	public EUDataGridResult getDesignList(int page, int rows) {
		HousedesignExample example = new HousedesignExample();
		//设置分页
		PageHelper.startPage(page, rows);
		
		List<Housedesign> list = housedesignMapper.selectByExample(example);
		//取分页信息
		PageInfo<Housedesign> pageInfo = new PageInfo<>(list);

		EUDataGridResult result = new EUDataGridResult();
		result.setRows(list);
		result.setTotal(pageInfo.getTotal());
		return result;
	}

	@Override
	public int delete(List<Integer> id) {
		// TODO Auto-generated method stub
		HousedesignExample example = new HousedesignExample();
		Criteria criteria = example.createCriteria();
		criteria.andIdIn(id);		
		return housedesignMapper.deleteByExample(example);
	}

	@Override
	public int add(Housedesign design) {
		// TODO Auto-generated method stub
		return housedesignMapper.insert(design);
	}

}
